/*
 * @Description: 大屏自适应
 * @Author: LiuYan
 * @Date: 2022-02-14 17:49:55
 * @LastEditTime: 2022-03-24 15:00:49
 * @LastEditors: LiuYan
 * @Reference:
 */
export default {
  mounted() {
    this.zoomView()
    window.onresize = () => {
      this.zoomView()
    }
  },
  beforeDestroy() {
    window.onresize = null
  },
  methods: {
    zoomView() {
      let maxView = this.$refs.maxView,
        viewWidth = parseInt(maxView.style.width),
        viewHeight = parseInt(maxView.style.height)
      // 设置缩放比例
      let w = window.innerWidth / viewWidth
      let h = window.innerHeight / viewHeight
      maxView.style.transform = `scale(${w},${h})`
    },
    // zoomView() {
    //   let maxView = this.$refs.maxView,
    //     viewWidth = parseInt(maxView.style.width),
    //     viewHeight = parseInt(maxView.style.height),
    //     clientRect = maxView.offsetParent.getBoundingClientRect()
    //   let scale = Math.min(clientRect.width / viewWidth, clientRect.height / viewHeight)
    //   maxView.style.transform = `scale(${scale} , ${scale})`
    // },
  },
}
